<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <meta charset="UTF-8">
	<title>Document</title>
	<meta name="viewport" content="initial-scale=1, width=device-width, maximum-scale=1, user-scalable=no">
	<link rel="stylesheet" type="text/css" href="css/index.css">
	<link rel="stylesheet" type="text/css" href="css/login.css">
	<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
	<script type="text/javascript">
	
	localStorage.sellerId = "";
	localStorage.imgHost = "";
	
	$(document).ready(function() {
		$(".lok-btn").click(function(event) {
			if ($(".psd-btn").attr("type") == "password") {
            $(".psd-btn").attr("type", "text");
             $(this).addClass('lok-btn-1')
        }
        else {
            $(".psd-btn").attr("type", "password");
             $(this).removeClass('lok-btn-1')
        }
		});
		 $(document).delegate("input","keydown",function(){
          
          	$(this).next(".close-btn").show();
          	$(this).next(".close-btn").next(".lok-btn").show();
     		$(".go-btn").addClass('go-ok')
  		});

		$(".go-btn").click(function(event) {
			//$(".comb").show()///密码不正确弹框
			login();
		});
		$(".close-btn").click(function(event) {
			$(this).prev("input.txt").val("")
		});
	});
	
	function hideMsg(){
		$(".comb").hide();
	}
	
	function showMsg(){
		$(".comb").show();
		setTimeout('hideMsg()',3000);
	}
	
	function login(){
		var accName = $.trim($("#accName").val());
		var accPass = $.trim($("#accPass").val());
		if(accName.length == 0){
			$(".errMsg").html("账号不能为空");
			showMsg();
			return;
		}
		if(accPass.length == 0){
			$(".errMsg").html("密码不能为空");
			showMsg();
			return;
		}
		$.ajax({
			type:"POST",
			url:"<%=path %>/seller/doLogin",
			data:{"accName":accName,
				"accPass":accPass},
			dataType:'Json',
			success:function(data){
				if(data.code == 1){
					localStorage.sellerId = data.sellerId;
					localStorage.imgHost = data.imgHost;
					var url = '<%=path %>/seller/orderList?sellerId='+localStorage.sellerId+'&t='+Math.random();
					//alert(url);
					location.href = url;
				}else{
					$(".errMsg").html(data.msg);
					showMsg();
				}
			}
		});
	}
	</script>
</head>
<body>
	<section class="log" >
		<div>
			<div class="men"><input type="text" class="txt" placeholder="请输入账号" id="accName" name="accName"><input type="button" class="close-btn" onclick="$('#accName').val('')"></div>
			<div class="pas"><input type="password" placeholder="请输入密码" class="txt psd-btn" id="accPass" name="accPass"><input type="button" class="close-btn" onclick="$('#accPass').val('')"> <input type="button" class="lok-btn"></div>
		</div>
	</section>
	<section class="sub">
		<div>
			<input type="button" class="go-btn" value="登录">
		</div>
	</section>
	<section class="comb">
		<div class="errMsg">您输入的密码不正确</div>
	</section>
</body>
</html>
